import type { Meta, StoryObj } from "@storybook/react"
import { Layout } from "antd"
import { IntlProvider } from "react-intl"
import { MemoryRouter } from "react-router"

import { localeConfig } from "@/locales"
import { sampleData } from "@/routes/sampleMenuData"

import GlobalSider from "."

const meta = {
	title: "GlobalSider",
	component: GlobalSider,
	tags: ["autodocs"]
} satisfies Meta<typeof GlobalSider>

export default meta
type Story = StoryObj<typeof meta>

export const GlobalSiderComponent: Story = {
	args: {
		menuData: sampleData,
		locale: "zh_CN"
	},
	render: args => {
		const locale = args.locale
		return (
			<MemoryRouter initialEntries={["/dataDashboard/dataDaily"]}>
				<IntlProvider locale={locale.split("_")[0]} messages={localeConfig[locale]}>
					<Layout>
						<GlobalSider {...args} menuData={sampleData} />
					</Layout>
				</IntlProvider>
			</MemoryRouter>
		)
	}
}
